import {requserlogin} from '../../http/api'
let state = {
    user:{
        username:'',
        password:''
    },
    // menus:JSON.parse(localStorage.getItem('user')).menus
}
let getters = {
    user(state){
        return state.user
    },
    menus(state){
        return state.menus
    }
   
}
let mutations = {
    changeUser(state,user){
        state.user = user;
    },
    changeMenus(state,menus){
        state.menus = menus
    }
}
let actions = {
    requser(context){
        requserlogin({...context.state.user,istree:true}).then(res => {
            context.commit('changeUser',res.data.list)
            localStorage.setItem('user',JSON.stringify(res.data.list))
        })
    },
    getMenus(context){
        context.commit('changeMenus',context.state.menus);
        console.log(context.state.menus);
    }
}
export default {
    state,
    actions,
    mutations,
    getters,
    namespaced: true
}